package ru.st.selenium.storage;
 
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
 
public class InMemoryStorage<K, V>
        implements Storage<K, V> {
 
    private final Map<K, V> map = new HashMap<K, V>();
 
    public V put(K key, V value) {
        synchronized (map) {
            return map.put(key, value);
        }
    }
 
    public V get(K key) {
        synchronized (map) {
            return map.get(key);
        }
    }
 
    public V remove(K key) {
        synchronized (map) {
            return map.remove(key);
        }
    }
 
    public Set<K> keySet() {
        synchronized (map) {
            return map.keySet();
        }
    }
}